﻿@model MvcForum.Web.Areas.Admin.ViewModels.ChoosePermissionsViewModel
@{
    ViewBag.Title = "Permission Types";
}
<div class="permissiontypes">

    <div class="row">

        <div class="col-md-6">
            <div class="panel">
                <div class="panel-heading">
                    <h5>Add Permissions</h5>
                </div>
                <div class="panel-content">
                    <p>It's super simple to add your own custom permissions to the forum, you firstly need to add it into the database using the button below.</p>
                    <p>
                        Then you after you have done that, you can check the permission based on the role (And Category). You just pull out the permission
                        from a PermissionSet using the name of the permission you just added to the database. We put all permission names into constants to make it easier. Example below.
                    </p>
                    <pre>
var permissions = RoleService.GetPermissions(category, UsersRole);
permissions["YourCustomPermissionName"].IsTicked</pre>
                    <p>Global permissions are returned with the call above, but if you just want to get global permissions you call the same method, but pass in null for the category.</p>
                    <pre>
var permissions = RoleService.GetPermissions(null, UsersRole);</pre>
                    <p>&nbsp;</p>
                    <p><a href="@Url.Action("AddType")" class="btn-mvc-green btn-mvc-large">Add New Permission Type</a></p>
                </div>
            </div>
        </div>

        <div class="col-md-6">

            <p><strong style="color: maroon; text-decoration: underline;">WARNING:</strong> Deleting permission types that are in use will break your forum, be VERY careful.</p>

            <div class="panel">
                <div class="panel-heading">
                    <h5>Current Permission Types</h5>
                </div>
                <ul class="list-group">
                    @foreach (var permission in Model.Permissions)
                    {
                        <li class="list-group-item">
                            <span class="badge">
                                <a href="@Url.Action("DeletePermission", "Permissions", new { id = permission.Id })" onclick="return confirm('Are you sure?')"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>
                            </span>
                            @permission.Name
                        </li>
                    }
                </ul>
            </div>

        </div>

    </div>

</div>
